package mi.payment.ui.other;

import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;

import mi.payment.R;
import mi.payment.ui.base.InputMoneyActivity;

public class OnlyInputAmountActivity extends InputMoneyActivity {

    public final static int RESULT_CODE = 998;
    public final static String RESULT_AMOUNT = "resultAmount";

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mBtnOk.setText(R.string.ok);
        mTvTitle.setText(R.string.money_input);
    }

    @Override
    public void onClick(View v) {
        if (v == mBtnOk) {
            clickOK();
        }
    }

    @Override
    public void onBackPressed() {
        Intent intent = new Intent();
        intent.putExtra(RESULT_AMOUNT, "");
        setResult(RESULT_CODE, intent);
        finish();
    }

    private void clickOK() {
        mInputAmount = amountInputView.getAmountText().toString();
        boolean equals = TextUtils.equals("0.00", mInputAmount);
        if (equals) {
            showToast(R.string.money_input_hint);
        } else {
            Intent intent = new Intent();
            intent.putExtra(RESULT_AMOUNT, mInputAmount);
            setResult(RESULT_CODE, intent);
            finish();
        }
    }


}
